package commands

import (
	"github.com/zw2582/ginlib"
	"log"
	"os"
	"szxf/models"
	"szxf/services"
)

func InitCommand()  {
	//DbQueueCommand 消费数据库操作队列
	go services.NewDbQueueService().Consume()

	//同步表结构 -- db_sync
	dbSync()
}

func dbSync()  {
	if len(os.Args) < 2 || os.Args[1] != "db_sync" {
		return
	}
	//同步表结构
	if err := ginlib.XormSync(models.DB); err != nil {
		log.Println(err.Error())
	}
	os.Exit(1)
}
